#include "moveaction.h"
#include <cstring>
#include <QDebug>

MoveAction::MoveAction(QObject *parent) : QObject(parent)
{
    this->client =  new TcpClient;
    connect(client, &TcpClient::error, this , &MoveAction::onConnectErr);
}

bool MoveAction::powerOff()
{

    return true;
}


void MoveAction::tryConnect(int id,QString ip, uint port)
{
    Q_UNUSED(id);

    connect(client, &TcpClient::error, [=](){
        emit emitConnectResult(false);
    });

    connect(client, &TcpClient::connected, [=](){
        emit emitConnectResult(true);
    });

    client->connectToServer(ip, port);
}

void MoveAction::onEmergency()
{

}

void MoveAction::onConnectErr(QAbstractSocket::SocketError)
{
    emit emitConnectResult(false);
}
